	implicit double complex (a-h,o-q,s-z)
	implicit real*8 (r)
	call base
	call delh
	call matrix
	end

	subroutine matrix
	parameter(nbase=1000,mxrd=1000)
	implicit double complex (a-h,o-q,s-z)
	implicit real*8 (r)
	real*8 at1,zt1,v_01,r_01,a1,v_so1
	real*8 at2,zt2,v_02,r_02,a2,v_so2
	common/ip/eip(nbase),ityip(nbase),jip(nbase),lip(nbase),nip
	common/c1pot/rrxmax,rixass,rrstep
	common/wfmat/wfmat(nbase,mxrd)
	common/vmat/rvmat(mxrd)
	dimension hsym(nbase,nbase),rar(nbase,nbase),rai(nbase,nbase)
	dimension rwr(nbase),rwi(nbase),rfv1(nbase),rfv2(nbase),rfv3(nbase)
	dimension rzr(nbase,nbase),rzi(nbase,nbase)
	nwf=rrxmax/rrstep
	do 101 ia=1,nip
	do 100 ib=1,nip
	hsym(ia,ib)=0.d0
	do j=1,nwf
	hsym(ia,ib)=hsym(ia,ib)+rvmat(j)*wfmat(ia,j)*wfmat(ib,j)*rrstep
c	print *,rvmat(j)
	enddo
	if(ia.eq.ib)hsym(ia,ib)=hsym(ia,ib)+eip(ia)
	rar(ia,ib)=dreal(hsym(ia,ib))
	rai(ia,ib)=dimag(hsym(ia,ib))
100	continue
101	continue
c	print *,hsym(1,1),hsym(1,2),hsym(2,1),hsym(2,2)
	call cg(nbase,nip,rar,rai,rwr,rwi,rzr,rzi,rfv1,rfv2,rfv3,ierr)
	do i=1,nip
	print *,i,rwr(i),rwi(i)
	write(20,*)i,rwr(i),rwi(i)
	enddo
	return
	end

	subroutine delh
	parameter(mxrd=1000)
	implicit double complex (a-h,o-q,s-z)
	implicit real*8 (r)
	common/c1pot/rrxmax,rixass,rrstep
	common/vmat/rvmat(mxrd)
	open(unit=8,file='pot1.out',status='old')
	open(unit=9,file='pot2.out',status='old')
	nwf=rrxmax/rrstep
	do i=1,nwf
	read(8,*)r1
	read(9,*)r2
	rvmat(i)=r2-r1
	enddo
	close(unit=8)
	close(unit=9)
	return
	end
